﻿using DosTexPrj.Core.Models;
using FluentNHibernate.Mapping;

namespace DosTexPrj.Implement.NHibernate.Mapping
{
    public class OrderDetailMapping : ClassMap<OrderDetail>
    {
        public OrderDetailMapping()
        {
            Table("OrdersDetail");
            Id(x => x.Id, "OrderDetailID").UnsavedValue(0).GeneratedBy.Identity();
            Map(x => x.KgQuantity, "KgQuantity").Not.Nullable();
            Map(x => x.MtQuantity, "MtQuantity").Not.Nullable();
            Map(x => x.Price, "Price").Not.Nullable();
            Map(x => x.Weight, "Weight").Not.Nullable();
            Map(x => x.CuttableWidth, "CuttableWidth").Not.Nullable();
            Map(x => x.Color, "Color").Not.Nullable().Length(200);
            Map(x => x.IsDone).Default("0");
            References<Order>(x => x.Order).Column("OrderID").Not.LazyLoad();
            References<Composition>(x => x.Composition).Column("CompositionID").Not.LazyLoad();
            References<FabricType>(x => x.FabricType).Column("FabricTypeID").Not.LazyLoad();
        }
    }
}